/*
 * Created on Mar 23, 2006
 *
 */
package org.mushroomdb.storedprocedures;

import java.util.List;

import org.mushroomdb.engine.EvaluationEngine;
import org.mushroomdb.query.Query;
import org.mushroomdb.service.ServiceManager;

/**
 * CREATE PROCEDURE procedure_name (options) AS LANGUAGE JAVA (<java-code>);
 * 
 * @author mchiodi
 */
public class CreateProcedureQuery extends Query {
	private String name;
	private List parameters;
	private String code;

	/**
	 * Constructs a new CreateProcedureQuery.
	 */
	public CreateProcedureQuery(String name, List parameters, String code) {
		super();
		this.name = name;
		this.parameters = parameters;
		this.code = code;
	}

	/**
	 * @see org.mushroomdb.query.Query#execute(org.mushroomdb.engine.EvaluationEngine)
	 */
	public Object execute(EvaluationEngine evaluationEngine) {
		StoredProceduresService storedProceduresService = (StoredProceduresService) ServiceManager.getInstance().getService(StoredProceduresService.class);
		storedProceduresService.addProcedure(new StoredProcedure(this.name,this.parameters,this.code));
		return Boolean.TRUE;
	}

}
